<template>
  <div class="pageWrapper">
    <common-header />
    <div class="card">
      <div class="title">回复内容</div>
      <textarea id="content" @click="onTextArea" v-model="submitForm.resultContent" placeholder="请输入异议回复内容"></textarea>
    </div>
    <div class="card">
      <div class="title required">处理状态</div>
      <div class="radio-group">
        <div class="radio-item" @click="submitForm.dissentStatus = 0">
          <div class="radio-circle" :class="{ active: submitForm.dissentStatus == 0 }"></div>
          <div class="label">未处理</div>
        </div>
        <div class="radio-item" @click="submitForm.dissentStatus = 1">
          <div class="radio-circle" :class="{ active: submitForm.dissentStatus == 1 }"></div>
          <div class="label">处理中</div>
        </div>
        <div class="radio-item" @click="submitForm.dissentStatus = 2">
          <div class="radio-circle" :class="{ active: submitForm.dissentStatus == 2 }"></div>
          <div class="label">处理完成</div>
        </div>
      </div>
    </div>
    <div class="submit-btn btn-active" @click="submit">提交</div>
  </div>
</template>

<script>
import { objectionUpdateResult } from "@/api/objectionHandle";
import { Toast } from "vant";
export default {
  created() { },
  data() {
    return {
      active: 0,
      submitForm: {
        id: "",
        dissentStatus: 0,
        resultContent: ""
      }
    };
  },
  created() {
    this.submitForm.id = this.$route.query.id;
  },
  methods: {
    onTextArea() {
      this.$nextTick(() => {
        document.querySelector('#content').focus();
      })
    },
    submit() {
      if (!this.submitForm.resultContent) {
        Toast("请输入回复内容");
        return;
      }
      objectionUpdateResult(this.submitForm).then(res => {
        if (res.code == 200) {
          this.$router.back();
        } else {
          Toast(res.msg);
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
.card {
  background: #fff;
  border-radius: 8px;
  margin: 20px 16px;
  padding: 16px;

  .title {
    line-height: 22px;
    color: #000;
    font-size: 16px;
    margin-bottom: 12px;

    &.required {
      position: relative;
      padding-left: 14px;

      &::before {
        content: "*";
        position: absolute;
        left: 0;
        top: 2px;
        color: #f60e36;
        font-size: 16px;
      }
    }
  }

  textarea {
    color: #333;
    font-size: 14px;
    line-height: 20px;
    padding: 0;
    border: none;
    width: 100%;
    resize: unset;
    height: 128px;

    &::placeholder {
      color: #b2b2b2;
    }
  }
}

.radio-group {
  display: flex;
  align-items: center;
  justify-content: space-between;

  .radio-item {
    display: flex;
    align-items: center;

    .radio-circle {
      position: relative;
      margin-right: 12px;
      width: 14px;
      height: 14px;
      border-radius: 50%;
      border: 1px solid #d6d6d6;

      &.active::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #2492ff;
      }
    }

    .label {
      color: #4d4d4d;
      font-size: 14px;
    }
  }
}

.submit-btn {
  position: fixed;
  left: 16px;
  bottom: 54px;
  width: 343px;
  text-align: center;
  line-height: 52px;
  border-radius: 12px;
  color: #fff;
  background: #2492ff;
  font-size: 14px;
}
</style>
